//Do-file to create SES data 1970-1990
	
***************Read in data on education from 1990**************************
	use LopNr Sun* using D:\SCB_ConPol\Stata\LISA\LISA_1990, clear
	bysort LopNr: egen cID=count(LopNr)
	drop if cID>1
	drop cID
	drop Sun2000Inr
	destring _all, replace force
	tempfile LISA90
	save `LISA90'
*****************************************************************************
	
***************Read in data on birth info******************************
	use "D:\SCB_ConPol\Stata\FlerGen\Fodelseuppg.dta", clear
	bysort LopNr: egen cID=count(LopNr)
	drop if cID>1
	drop cID
	keep LopNr FodArMan Kon
	
	tempfile FodUppg
	save `FodUppg'
	
	cd D:\SCB_ConPol\Stata\FoB


*******************Read in data from census 1970************************************	
	use FoB_70, clear
	drop if AterPnr==1
	destring _all, replace force
	keep LopNr UtbNiva
	gen Ar = 1970
	
	tempfile FoB70
	save `FoB70'
	
	
*******************Lägg till födelseuppgifter***********************************
	merge m:1 LopNr using `FodUppg'
	keep if _merge==3
	drop _merge

*******************Lägg till utbildningsdata från 1990**************************
	
	merge m:1 LopNr using `LISA90'
	rename Sun2000niva_old UtbNiva_1990
	rename UtbNiva UtbNiva_1970

//Använd den högsta utbildningen 1970 vs. 1990	
	gen UtbNiva = max(UtbNiva_1970, UtbNiva_1990)

	
	
	compress
	drop _merge
	save "D:\Data\ProjData\SiblingOrder\SESData7090.dta", replace
	clear all 
	exit
	
